//
//  MapGrid.cpp
//  DiceWar
//
//  Created by Xiao  Feng on 17/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include "HexMapGrid.h"

HexMapGrid::HexMapGrid()
: m_type(kWall)
, m_playerType(kInvalidPlayer)
, m_numDices(0)
, m_positionX(0)
, m_positionY(0)
, m_coordinateX(0)
, m_coordinateY(0){}

HexMapGrid::~HexMapGrid() {}

HexMapGrid::HexMapGrid(const HexMapGrid& other)
: m_type(other.m_type)
, m_coordinateX(other.m_coordinateX)
, m_coordinateY(other.m_coordinateY)
, m_positionX(other.m_positionX)
, m_positionY(other.m_positionY)
, m_playerType(other.m_playerType)
, m_numDices(other.m_numDices) {}

HexMapGrid& HexMapGrid::operator=(const HexMapGrid& other)
{
    m_type = other.m_type;
    m_positionX = other.m_positionX;
    m_positionY = other.m_positionY;
    m_coordinateX = other.m_coordinateX;
    m_coordinateY = other.m_coordinateY;
    m_playerType = other.m_playerType;
    m_numDices = other.m_numDices;
    return *this;
}

void HexMapGrid::setCoordinate(int coordinateX, int coordinateY)
{
    m_coordinateX = coordinateX;
    m_coordinateY = coordinateY;
}

HexCellCoordinate HexMapGrid::getCoordinate() const
{
    return HexCellCoordinate(m_coordinateX, m_coordinateY);
}

void HexMapGrid::setPosition(const cocos2d::CCPoint& position)
{
    m_positionX = position.x;
    m_positionY = position.y;
}

cocos2d::CCPoint HexMapGrid::getPosition() const
{
    return ccp(m_positionX, m_positionY);
}

bool HexMapGrid::isOwnedByPlayer(PlayerType player) const
{
    return isPlayable() && m_playerType == player;
}
